﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="administrator.aspx.cs" Inherits="WL_Store.Web.subpage.administrator" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="../css/style.css" />
    <link href="../assets/css/codemirror.css" rel="stylesheet" />
    <link rel="stylesheet" href="../assets/css/ace.min.css" />
    <link rel="stylesheet" href="../font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->
    <script src="../js/jquery-1.9.1.min.js"></script>
    <script src="../assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="../assets/js/typeahead-bs2.min.js"></script>
    <script src="../assets/js/jquery.dataTables.min.js"></script>
    <script src="../assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="../assets/layer/layer.js" type="text/javascript"></script>
    <script src="../js/lrtk.js" type="text/javascript"></script>
    <script src="../assets/layer/layer.js" type="text/javascript"></script>
    <script src="../assets/laydate/laydate.js" type="text/javascript"></script>
    <script src="../My97DatePicker/WdatePicker.js"></script>
    <title>管理员</title>
   <style>
        #tb_admin  th {
            text-align: center;
              
        }

        .add_name span {
            color: red;
        }
        /*#tb_admin td{
        padding:4px;
         
         text-align:center;
        }
        #tb_admin tr {
        height:40px;
        
        background-color:#f0ceff;
        }
      
        #tb_admin {
        border-collapse:collapse;
        margin:0 auto;
        
        }*/
       .page {
       margin:0 auto;
       display: block;
       margin-top:20px;
       }
    </style>
    <script>

        $(function () {

            //加载层-风格3
           layer.load(2);
            //此处演示关闭
            setTimeout(function () {
                layer.closeAll('loading');
            }, 500);

            $('.delAjax').click(function () {

                if (confirm("你确定要删除吗？")) {
                    
                    var delId = $(this).attr("delid");
                    $.post("/ashx/AdminInfo.ashx", { DelId: delId, Action: "Delete" }, function (data) {
                        if (data.State == 1) {
                            
                            alert(data.Message);
                            location.reload();
                        }
                        else {
                            
                            alert(data.Message);
                        }


                    },"json");


                }
                });
            //iframe层-父子操作

            $('.edit').click(function () {
                var number = $(this).attr("editId");
                layer.open({
                    type: 2,
                    load:2,
                    area: ['700px', '450px'],
                    fixed: false, //不固定
                    maxmin: true,
                    skin: 'layer-ext-moon',
                    content: 'administrator_edit.aspx?number=' + number,
                    end: function () {
                        location.reload();
                    }
                });

            });

            

            


        });
    </script>


</head>
<body>

    <form id="form1" runat="server">
        <div class="page-content clearfix">
            <div class="administrator">
                <div class="d_Confirm_Order_style">
                    <div class="search_style">

                        <ul class="search_content clearfix">
                            <li>
                                <label class="l_f">管理员名称:</label>
                                
                                <asp:TextBox ID="txt_search_name" runat="server" class="text_add" style="width: 200px" ></asp:TextBox>

                            </li>
                            <li>
                                <label class="l_f">入职时间:</label>
                               
                                <input id="txt_StartEntrytime" runat="server" class="inline laydate-icon" onclick="WdatePicker({ isShowClear: true, readOnly: true })" />
                                <label>至</label>
                                 <input id="txt_EndEntrytime" runat="server" class="inline laydate-icon" onclick="WdatePicker({ isShowClear: true, readOnly: true })" />
                            </li>
                            <li>
                                <label class="l_f">管理权限:</label>
                                <asp:DropDownList ID="ddl_PermissionInfo" runat="server" class="text_add"  style="margin-left: 10px;" ></asp:DropDownList>

                            </li>
                            <li >
                                <label class="l_f">性别:</label>
                                <asp:RadioButtonList ID="rbl_search_sex" runat="server" RepeatDirection="Horizontal"  >
                                    <asp:ListItem Value="0">&nbsp;&nbsp;男&nbsp;&nbsp;</asp:ListItem>
                                    <asp:ListItem Value="1">&nbsp;&nbsp;女&nbsp;&nbsp;</asp:ListItem>
                                    <asp:ListItem Value="-1" Selected="True">&nbsp;&nbsp;不限&nbsp;&nbsp;</asp:ListItem>

                                </asp:RadioButtonList>

                            </li>

                            <li style="width: 90px;">
                                <%--<i class="fa fa-search" style="margin-left: 20px;margin-top: 7px;position: absolute;color: wheat;font-size: 19px;"></i>--%>
                                <asp:Button ID="btn_search" runat="server" Text="检索" class="btn_search" OnClick="btn_search_Click" CausesValidation="false" />
                            </li>
                        </ul>
                    </div>
                    <!--操作-->
                    <div class="border clearfix">
                        <span class="l_f">
                            <a href="javascript:ovid()" id="administrator_add" class="btn btn-warning"><i class="fa fa-plus"></i>添加管理员</a>
                            <%--<a href="javascript:ovid()" class="btn btn-danger"><i class="fa fa-trash"></i>批量删除</a>--%>
                        </span>
                        <span class="r_f">共：<b>5</b>人</span>
                    </div>

                    <!--管理员列表-->

                    <div class="clearfix administrator_style" id="administrator">

                         <table id="tb_admin" class="table  table-bordered table-hover dataTable no-footer">
                            <tr>
                                <th>编号</th>
                                <th>姓名</th>
                                <th>登录名</th>
                                <th>级别</th>
                                <th>性别</th>
                                <th>年龄</th>
                                <th>身份证号码</th>
                                <th>电话</th>
                                <th>电子邮箱</th>
                                <th>地址</th>
                                <th>入职时间</th>
                                <th>注册时间</th>
                                
                                
                                <th style="width:180px">操作</th>
                            </tr>
                            <asp:Repeater ID="rpt_admin" runat="server">
                                <ItemTemplate>
                                    <tr>
                                <td><%# Eval("number") %></td>
                                <td><%# Eval("name") %></td>
                                <td><%# Eval("loginName") %></td>
                                <td><%# Eval("Grade") %></td>
                                <td><%# Eval("sexName") %></td>
                                <td><%# Eval("age") %></td>
                                <td><%# Eval("idcard") %></td>
                                <td><%# Eval("phone") %></td>
                                <td><%# Eval("email") %></td>
                                <td><%# Eval("address") %></td>
                                <td><%# Eval("entrytime") %></td>
                                <td><%# Eval("regtime") %></td>
                              
                                
                                <td>
                                    <a href='javacript:;' class="edit btn btn-sm btn-success" editId="<%# Eval("number") %>"><i class="fa fa-edit bigger-120"></i>编辑</a>
                                    <asp:LinkButton ID="lbt_del" CssClass="del btn btn-sm btn-danger"  runat="server" CommandName="del" CommandArgument='<%# Eval("number") %>' OnCommand="lbt_del_Command" OnClientClick="return confirm('你确定要删除吗？')" CausesValidation="false"><i class="fa fa-trash  bigger-120"></i>删除</asp:LinkButton>
                                    <%--<a href="javacript:void(0);" class="delAjax" delid="<%# Eval("number") %>">删除Ajax</a>--%>
                                </td>
                            </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </table>
                        <webdiyer:AspNetPager ID="user_Pager" runat="server" UrlPaging="true" AlwaysShow="true" 
                    FirstPageText="首页" LastPageText="末页" 
                    NextPageText="下一页" PrevPageText="上一页" CustomInfoHTML="目前是第%CurrentPageIndex%页 / 总共%PageCount%页" 
                    ShowCustomInfoSection="Right" PagingButtonSpacing="0" NumericButtonCount="5"
                    CssClass="pagination page" LayoutType="Ul" PagingButtonLayoutType="UnorderedList" CurrentPageButtonClass="active"  Width="850px" OnPageChanging="user_Pager_PageChanging">
                </webdiyer:AspNetPager>
                    </div>
             

                </div>

            </div>
            
            <!--添加管理员-->
            <div id="add_administrator_style" class="add_menber" style="display: none">

                <div class="form-group">
                    <label class="form-label"><span class="c-red">*</span>编号：</label>
                    <div class="formControls">
                        <%--<input type="text" class="input-text" value="" placeholder="" id="user-name" name="user-name" datatype="*2-16" nullmsg="用户名不能为空">--%>
                        <asp:TextBox ID="txt_number" runat="server" placeholder="编号"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="编号不能为空" ControlToValidate="txt_number"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label"><span class="c-red">*</span>姓名：</label>
                    <div class="formControls">
                        <%--<input type="password" placeholder="密码" name="userpassword" autocomplete="off" value="" class="input-text" datatype="*6-20" nullmsg="密码不能为空">--%>
                        <asp:TextBox ID="txt_name" runat="server" placeholder="姓名"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="姓名不能为空" ControlToValidate="txt_name"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label "><span class="c-red">*</span>级别：</label>
                    <div class="formControls ">
                        <%--<input type="password" placeholder="确认新密码" autocomplete="off" class="input-text Validform_error" errormsg="您两次输入的新密码不一致！" datatype="*" nullmsg="请再输入一次新密码！" recheck="userpassword" id="newpassword2" name="newpassword2">--%>
                        <asp:DropDownList ID="ddl_rank" runat="server"></asp:DropDownList>

                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label "><span class="c-red">*</span>性别：</label>
                    <div class=" radio-inline" >
                        <asp:RadioButtonList ID="rbt_sex" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Selected="True" Value="0">&nbsp;&nbsp;男&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</asp:ListItem>
                            <asp:ListItem Value="1">&nbsp;&nbsp;女</asp:ListItem>

                        </asp:RadioButtonList>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label "><span class="c-red">*</span>年龄：</label>
                    <div class="formControls ">
                        <%--<input type="text" class="input-text" value="" placeholder="" id="user-tel" name="user-tel" datatype="m" nullmsg="手机不能为空"/>--%>
                        <asp:TextBox ID="txt_age" runat="server" placeholder="年龄"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="年龄不能为空" ControlToValidate="txt_age"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label"><span class="c-red">*</span>身份证号：</label>
                    <div class="formControls ">
                        <%--<input type="text" class="input-text" placeholder="@" name="email" id="email" datatype="e" nullmsg="请输入邮箱！"/>--%>
                        <asp:TextBox ID="txt_idcard" runat="server" placeholder="身份证号"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="身份证号不能为空" ControlToValidate="txt_idcard"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label"><span class="c-red">*</span>电话：</label>
                    <div class="formControls ">
                        <asp:TextBox ID="txt_phone" runat="server" placeholder="电话"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="电话不能为空" ControlToValidate="txt_phone"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label">电子邮箱：</label>
                    <div class="formControls">
                        <asp:TextBox ID="txt_email" runat="server" placeholder="电子邮箱"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="电子邮箱不能为空" ControlToValidate="txt_email"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"></div>
                </div>
                <div class="form-group">
                    <label class="form-label"><span class="c-red">*</span>地址：</label>
                    <div class="formControls ">
                        <asp:TextBox ID="txt_addss" runat="server" placeholder="地址"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="地址不能为空" ControlToValidate="txt_addss"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
             
                <div class="form-group">
                    <label class="form-label"><span class="c-red">*</span>登录名：</label>
                    <div class="formControls ">
                        <asp:TextBox ID="txt_loginName" runat="server" placeholder="登录名"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ErrorMessage="登录名不能为空" ControlToValidate="txt_loginName"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label"><span class="c-red">*</span>登录密码：</label>
                    <div class="formControls ">
                        <asp:TextBox ID="txt_loginPassword" runat="server" placeholder="登录密码"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="登录密码不能为空" ControlToValidate="txt_loginPassword"></asp:RequiredFieldValidator>
                    </div>
                    <div class="col-4"><span class="Validform_checktip"></span></div>
                </div>
                <div>
                    <%--<input class="btn btn-primary radius" type="submit" id="Add_Administrator" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"/>--%>
                    <asp:Button ID="btn_add" runat="server" Text="添加" class="btn btn-primary radius" OnClick="btn_add_Click" style="margin-left: 230px;" />
                </div>

            </div>
           
           
           
              
        </div>
             
    </form>


</body>
</html>
<script type="text/javascript">
    jQuery(function ($) {

        var oTable1 = $('#sample_table').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                { "orderable": false, "aTargets": [0, 2, 3, 4, 5, 7, 8,] }// 制定列不参与排序
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({ placement: tooltip_placement });
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    });

</script>
<script type="text/javascript">

    $(function () {
        $("#administrator").fix({
            float: 'left',
            //minStatue : true,
            skin: 'green',
            durationTime: false,
            spacingw: 50,//设置隐藏时的距离
            spacingh: 270,//设置显示时间距
        });
    });
    //字数限制
    function checkLength(which) {
        var maxChars = 100; //
        if (which.value.length > maxChars) {
            layer.open({
                icon: 2,
                title: '提示框',
                content: '您输入的字数超过限制!',
            });
            // 超过限制的字数了就将 文本框中的内容按规定的字数 截取
            which.value = which.value.substring(0, maxChars);
            return false;
        } else {
            var curr = maxChars - which.value.length; //250 减去 当前输入的
            document.getElementById("sy").innerHTML = curr.toString();
            return true;
        }
    };
    //初始化宽度、高度  
    $(".widget-box").height($(window).height() - 215);
    $(".table_menu_list").width($(window).width() - 260);
    $(".table_menu_list").height($(window).height() - 215);
    //当文档窗口发生改变时 触发  
    $(window).resize(function () {
        $(".widget-box").height($(window).height() - 215);
        $(".table_menu_list").width($(window).width() - 260);
        $(".table_menu_list").height($(window).height() - 215);
    })
    //laydate({
    //    elem: '#txt_StartEntrytime',
    //    event: 'focus'
    //});
    //laydate({
    //    elem: '#txt_EndEntrytime',
    //    event: 'focus'
    //});

    /*用户-停用*/
    function member_stop(obj, id) {
        layer.confirm('确认要停用吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="fa fa-close bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
            $(obj).remove();
            layer.msg('已停用!', { icon: 5, time: 1000 });
        });
    }
    /*用户-启用*/
    function member_start(obj, id) {
        layer.confirm('确认要启用吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="fa fa-check  bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
            $(obj).remove();
            layer.msg('已启用!', { icon: 6, time: 1000 });
        });
    }
    /*产品-编辑*/
    function member_edit(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }

    /*产品-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $(obj).parents("tr").remove();
            layer.msg('已删除!', { icon: 1, time: 1000 });
        });
    }
    /*添加管理员*/
    $('#administrator_add').on('click', function () {

        layer.open({
            type: 1,
            title: '添加管理员',
            area: ['500px', '550px'],
            shadeClose: false,
            content: $('#add_administrator_style'),


        });
    })
    //表单验证提交
    $("#form-admin-add").Validform({

        tiptype: 2,

        callback: function (data) {
            //form[0].submit();
            if (data.status == 1) {
                layer.msg(data.info, { icon: data.status, time: 1000 }, function () {
                    location.reload();//刷新页面 
                });
            }
            else {
                layer.msg(data.info, { icon: data.status, time: 3000 });
            }
            var index = parent.$("#iframe").attr("src");
            parent.layer.close(index);
            //
        }


    });
    /*编辑管理员*/
    //$(function () {
    //    $('.administrator_edit').on('click', function () {
    //        //$(this).attr("type","button");
    //        layer.open({ type: 1, title: '编辑管理员', area: ['700px', ''], content: $('#edit_administrator_style'), });
    //        //$.ajax({
    //        //    type: "post",
    //        //    url: "administrator.aspx/Edit",
    //        //    dataType: "json",
    //        //    contentType: "application/json; charset=utf-8",
    //        //    success: function () {
                   
    //        //    }
    //        //});
           
    //    });
    //});

    $('.administrator_edit').on('click', function () {
        layer.open({ type: 1, title: '编辑管理员', area: ['700px', ''], content: $('#edit_administrator_style'), });
        //return false;
    });


    //表单验证提交
    //$("#form1").Validform({

    //    tiptype: 2,

    //    callback: function (data) {
    //        //form[0].submit();
    //        if (data.status == 1) {
    //            layer.msg(data.info, { icon: data.status, time: 1000 }, function () {
    //                location.reload();//刷新页面 
    //            });
    //        }
    //        else {
    //            layer.msg(data.info, { icon: data.status, time: 3000 });
    //        }
    //        var index = parent.$("#iframe").attr("src");
    //        parent.layer.close(index);
    //        //
    //    }    //$("#form-admin-add").Validform({

    //    tiptype: 2,
    //    callback: function (data) {
    //        //form[0].submit();
    //        if (data.status == 1) {
    //            layer.msg(data.info, { icon: data.status, time: 1000 }, function () {
    //                location.reload();//刷新页面 
    //            });
    //        }
    //        else {
    //            layer.msg(data.info, { icon: data.status, time: 3000 });
    //        }
    //        var index = parent.$("#iframe").attr("src");
    //        parent.layer.close(index);
    //        //
    //    }


    //});	
</script>

